Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
npm install colorts
import 'colorts/lib/string';
console.log('hello'.green); // outputs green text
console.log('i like cake and pies'.underline.red) // outputs red underlined text
console.log('inverse the color'.inverse); // inverses the color
import color from 'colorts';
import {echo} from 'colorts';
console.log(colors('hello').green + ""); // outputs green text
console.log(colors('i like cake and pies').red.underline.toString) // outputs red underlined text
echo(colors('inverse the color').inverse); // you can use echo to console.log safe colorts
require('colorts/lib/string');
console.log('hello'.green); // outputs green text
console.log('i like cake and pies'.underline.red) // outputs red underlined text
console.log('inverse the color'.inverse); // inverses the color
let color = require('colorts');
let echo = require('colorts').echo;
console.log(colors('hello').green + ""); // outputs green text
console.log(colors('i like cake and pies').red.underline.toString) // outputs red underlined text
echo(colors('inverse the color').inverse); // you can use echo to console.log safe colorts
I prefer the first way. Some people seem to be afraid of extending String.prototype
and prefer the second way.
If you are writing good code you will never have an issue with the first approach. If you really don't want to
touch String.prototype
, the second usage will not touch String
native object.
To disable colors you can pass the following arguments in the command line to your application:
node myapp.js --no-color
"james is a nice guy.".capitalize // James is nice guy.
" no one home.".capitalize // No one home.
"typescript".capitalize // Typescript
"1st january 2018".capitalize // 1st january 2018
"james is a nice guy.".titleCase // James Is Nice Guy.
" no one home.".titleCase // No One Home.
"tYpe scrIpt".titleCase // Type Script
"1st january".titleCase // 1st January 2018
"james is a nice guy.".camelCase // jamesIsANiceGuy.
" no one home.".camelCase // nOneHome.
"type script".camelCase // typeScript
"james is a nice guy.".upperCamelCase // JamesIsANiceGuy.
" no one home.".upperCamelCase // NOneHome.
"type script".upperCamelCase // TypeScript
"james is a nice guy.".lowerCamelCase // jamesIsANiceGuy.
" no one home.".lowerCamelCase // nOneHome.
"type script".lowerCamelCase // typeScript
"james is a nice guy.".snakeCase // james_is_nice_guy.
" no one home.".snakeCase // no_one_home.
"super type script".snakeCase // super_type_script
"James is a nice guy.".kebabCase // james-is-nice-guy.
" no one home.".kebabCase // no-one-home.
"super type script".kebabCase // super-type-script
"james is a nice guy.".studlyCaps // JaMeSiSnIcEgUy.
" no one home.".studlyCaps // NoOnEhOmE.
"super type script".studlyCaps // SuPeRtYpEsCrIpT
FAQs
Colors in node Js console
The npm package colorts receives a total of 1,079 weekly downloads. As such, colorts popularity was classified as popular.
We found that colorts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.